home *** CD-ROM | disk | FTP | other *** search
- Path: nwgw.infi.net!usenet
- From: Steve Rountree <srndtree@infi.net>
- Newsgroups: comp.lang.c
- Subject: Re: Pattern matching in C
- Date: Wed, 28 Feb 1996 18:24:53 -0800
- Organization: InfiNet
- Message-ID: <31350E75.3DBD@infi.net>
- References: <4gjo68$jpp@paperboy.ids.net> <31349B7D.167E@mozart.bme.ohio-state.edu>
- NNTP-Posting-Host: h-bookplate.dc.infi.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b5 (Win16; I)
-
- scarney wrote:
- > >
- > > I'm trying to do some text file pattern matching. Using a simple while
- > > loop that has a <data> != <j.random string> in its conditional doesn't
- > > work. Depending on different ways of doing it, you get a segmentation
- > > fault, random output, or no output.
- > >
- > > Anybody know how I SHOULD be doing this?
- >
-
- Assuming both <data> and <j.random string> are both character arrays or
- pointers to characters then I would think that:
-
- #include<string.h>
- .
- .
- .
-
- if(strcmp(data,j.random_string)){ /* if you are looking for non-match
- */
- do something;
- }
-
- should work for you. A segment violation I believe would indicate that
- you have an unintialized pointer or array in your comparison.
-
-
- Steve Rountree
-